/**
 * File Comment: Ita a GUI
 */
package edu.gatech.oad.project.presentation;
//$codepro.audit.disable
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;

import edu.gatech.oad.project.operations.data.Appointment;

/**
 * This class is a panel that allows the user
 * to interact with the GUI to view a patient's
 * treatment record.
 * 
 * @author Group 17
 * @version 1
 */
public class SysAdminPatientTR extends JPanel {
  
  /**
   * Field driver: holds the Driver connected to the GUI
   */
  private Driver driver;
  
  /**
   * Field app: the Appointment the treatment record is for
   */
  private Appointment app;
  
  /**
   * Field textField: name
   */
 private JTextField textField;
 
 /**
  * Field textField_1: date
  */
 private JTextField textField_1;
 
 /**
  * Field textField_2: doctor
  */
 private JTextField textField_2;
 
 /**
  * Field textField_3: nurse
  */
 private JTextField textField_3;
 
 /**
  * Field symp: symptoms
  */
 private JTextField symp;
 
 /**
  * Field vit: vitals
  */
 private JTextField vit;
 
 /**
  * Field diag: diagnosis
  */
 private JTextField diag;
 
 /**
  * Field docord: doctor's orders
  */
 private JTextField docord;
 
 /**
  * Field btnEdit: edit button
  */
 public JButton btnEdit;
 
 /**
  * Field btnBackToPatient: back button
  */
 public JButton btnBackToPatient;
 
 /**
  * Field name: name
  */
 private String name;
 
 /**
  * Field date: date
  */
 private String date;
 
 /**
  * Field doctor: doctor
  */
 private String doctor;
 
 /**
  * Field nurse: nurse
  */
 private String nurse;
 
 /**
  * Field symptoms: symptoms
  */
 private String symptoms;
 
 /**
  * Field vitals: vitals
  */
 private String vitals;
 
 /**
  * Field diagnosis: diagnosis
  */
 private String diagnosis;
 
 /**
  * Field doctorsOrders: doctor's orders
  */
 private String doctorsOrders;

 /**
  * Constructor.
  * 
  * @param driver the Driver connected to the GUI
  * @param app the Appointment the treatment record is for
  */
 public SysAdminPatientTR(Driver driver, Appointment app) {
   this.driver = driver;
   this.app = app;
  GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[]{0, 0, 0, 0};
  gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
  gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, 1.0};
  gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
  setLayout(gridBagLayout);
  
  JLabel lblEditPatient = new JLabel("Patient Treatment Record");
  lblEditPatient.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
  GridBagConstraints gbc_lblEditPatient = new GridBagConstraints();
  gbc_lblEditPatient.gridwidth = 5;
  gbc_lblEditPatient.insets = new Insets(0, 0, 5, 0);
  gbc_lblEditPatient.gridx = 0;
  gbc_lblEditPatient.gridy = 0;
  add(lblEditPatient, gbc_lblEditPatient);
  
  JLabel lblName = new JLabel("Name");
  GridBagConstraints gbc_lblName = new GridBagConstraints();
  gbc_lblName.anchor = GridBagConstraints.EAST;
  gbc_lblName.insets = new Insets(0, 0, 5, 5);
  gbc_lblName.gridx = 0;
  gbc_lblName.gridy = 1;
  add(lblName, gbc_lblName);
  
  textField = new JTextField();
  textField.addCaretListener(new CaretListener() {
      public void caretUpdate(CaretEvent e) {
      name = textField.getText();
    }
  });
  GridBagConstraints gbc_textField = new GridBagConstraints();
  gbc_textField.insets = new Insets(0, 0, 5, 5);
  gbc_textField.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField.gridx = 1;
  gbc_textField.gridy = 1;
  add(textField, gbc_textField);
  textField.setColumns(10);
  
  JLabel lblDate = new JLabel("Date & Time");
  GridBagConstraints gbc_lblDate = new GridBagConstraints();
  gbc_lblDate.anchor = GridBagConstraints.EAST;
  gbc_lblDate.insets = new Insets(0, 0, 5, 5);
  gbc_lblDate.gridx = 2;
  gbc_lblDate.gridy = 1;
  add(lblDate, gbc_lblDate);
  
  textField_1 = new JTextField();
    textField_1.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      date = textField_1.getText();
    }
  });
  GridBagConstraints gbc_textField_1 = new GridBagConstraints();
  gbc_textField_1.insets = new Insets(0, 0, 5, 5);
  gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_1.gridx = 3;
  gbc_textField_1.gridy = 1;
  add(textField_1, gbc_textField_1);
  textField_1.setColumns(10);
  
  JLabel lblDoctor = new JLabel("Doctor");
  GridBagConstraints gbc_lblDoctor = new GridBagConstraints();
  gbc_lblDoctor.anchor = GridBagConstraints.EAST;
  gbc_lblDoctor.insets = new Insets(0, 0, 5, 5);
  gbc_lblDoctor.gridx = 0;
  gbc_lblDoctor.gridy = 2;
  add(lblDoctor, gbc_lblDoctor);
  
  textField_2 = new JTextField();
    textField_2.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      doctor = textField_2.getText();
    }
  });
  GridBagConstraints gbc_textField_2 = new GridBagConstraints();
  gbc_textField_2.insets = new Insets(0, 0, 5, 5);
  gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_2.gridx = 1;
  gbc_textField_2.gridy = 2;
  add(textField_2, gbc_textField_2);
  textField_2.setColumns(10);
  
  JLabel lblAttendingNurse = new JLabel("Attending Nurse");
  GridBagConstraints gbc_lblAttendingNurse = new GridBagConstraints();
  gbc_lblAttendingNurse.insets = new Insets(0, 0, 5, 5);
  gbc_lblAttendingNurse.gridx = 2;
  gbc_lblAttendingNurse.gridy = 2;
  add(lblAttendingNurse, gbc_lblAttendingNurse);
  
  textField_3 = new JTextField();
    textField_3.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      nurse = textField_3.getText();
    }
  });
  GridBagConstraints gbc_textField_3 = new GridBagConstraints();
  gbc_textField_3.insets = new Insets(0, 0, 5, 5);
  gbc_textField_3.fill = GridBagConstraints.HORIZONTAL;
  gbc_textField_3.gridx = 3;
  gbc_textField_3.gridy = 2;
  add(textField_3, gbc_textField_3);
  textField_3.setColumns(10);
  
  JLabel lblSymptoms = new JLabel("Symptoms");
  GridBagConstraints gbc_lblSymptoms = new GridBagConstraints();
  gbc_lblSymptoms.anchor = GridBagConstraints.EAST;
  gbc_lblSymptoms.insets = new Insets(0, 0, 5, 5);
  gbc_lblSymptoms.gridx = 0;
  gbc_lblSymptoms.gridy = 3;
  add(lblSymptoms, gbc_lblSymptoms);
  
  symp = new JTextField();
    symp.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      symptoms = symp.getText();
    }
  });
  GridBagConstraints gbc_textPane = new GridBagConstraints();
  gbc_textPane.insets = new Insets(0, 0, 5, 5);
  gbc_textPane.fill = GridBagConstraints.BOTH;
  gbc_textPane.gridx = 1;
  gbc_textPane.gridy = 3;
  add(symp, gbc_textPane);
  
  JLabel lblVitalSigns = new JLabel("Vital Signs");
  GridBagConstraints gbc_lblVitalSigns = new GridBagConstraints();
  gbc_lblVitalSigns.anchor = GridBagConstraints.EAST;
  gbc_lblVitalSigns.insets = new Insets(0, 0, 5, 5);
  gbc_lblVitalSigns.gridx = 2;
  gbc_lblVitalSigns.gridy = 3;
  add(lblVitalSigns, gbc_lblVitalSigns);
  
  vit = new JTextField();
    vit.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      vitals = vit.getText();
    }
  });
  GridBagConstraints gbc_textPane_1 = new GridBagConstraints();
  gbc_textPane_1.insets = new Insets(0, 0, 5, 5);
  gbc_textPane_1.fill = GridBagConstraints.BOTH;
  gbc_textPane_1.gridx = 3;
  gbc_textPane_1.gridy = 3;
  add(vit, gbc_textPane_1);
  
  JLabel lblDiagnosis = new JLabel("Diagnosis");
  GridBagConstraints gbc_lblDiagnosis = new GridBagConstraints();
  gbc_lblDiagnosis.anchor = GridBagConstraints.EAST;
  gbc_lblDiagnosis.insets = new Insets(0, 0, 5, 5);
  gbc_lblDiagnosis.gridx = 0;
  gbc_lblDiagnosis.gridy = 4;
  add(lblDiagnosis, gbc_lblDiagnosis);
  
  diag = new JTextField();
    diag.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      diagnosis = diag.getText();
    }
  });
  GridBagConstraints gbc_textPane_2 = new GridBagConstraints();
  gbc_textPane_2.gridheight = 2;
  gbc_textPane_2.insets = new Insets(0, 0, 5, 5);
  gbc_textPane_2.fill = GridBagConstraints.BOTH;
  gbc_textPane_2.gridx = 1;
  gbc_textPane_2.gridy = 4;
  add(diag, gbc_textPane_2);
  
  JLabel lblDoctorsOrders = new JLabel("Doctor's Orders");
  GridBagConstraints gbc_lblDoctorsOrders = new GridBagConstraints();
  gbc_lblDoctorsOrders.anchor = GridBagConstraints.EAST;
  gbc_lblDoctorsOrders.insets = new Insets(0, 0, 5, 5);
  gbc_lblDoctorsOrders.gridx = 2;
  gbc_lblDoctorsOrders.gridy = 4;
  add(lblDoctorsOrders, gbc_lblDoctorsOrders);
  
  docord = new JTextField();
    docord.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
      doctorsOrders = docord.getText();
    }
  });
  GridBagConstraints gbc_textPane_3 = new GridBagConstraints();
  gbc_textPane_3.gridheight = 2;
  gbc_textPane_3.insets = new Insets(0, 0, 5, 5);
  gbc_textPane_3.fill = GridBagConstraints.BOTH;
  gbc_textPane_3.gridx = 3;
  gbc_textPane_3.gridy = 4;
  add(docord, gbc_textPane_3);
  
  btnEdit = new JButton("Edit");
  btnEdit.addActionListener(new ButtonListener1(this));
  GridBagConstraints gbc_btnEdit = new GridBagConstraints();
  gbc_btnEdit.insets = new Insets(0, 0, 0, 5);
  gbc_btnEdit.gridx = 1;
  gbc_btnEdit.gridy = 6;
  add(btnEdit, gbc_btnEdit);
  
  btnBackToPatient = new JButton("Back to Treatment Records");
  btnBackToPatient.addActionListener(new ButtonListener2(this));
  GridBagConstraints gbc_btnBackToPatient = new GridBagConstraints();
  gbc_btnBackToPatient.insets = new Insets(0, 0, 0, 5);
  gbc_btnBackToPatient.gridwidth = 2;
  gbc_btnBackToPatient.gridx = 2;
  gbc_btnBackToPatient.gridy = 6;
  add(btnBackToPatient, gbc_btnBackToPatient);
 } // end constructor method
 
 /**
  * Get the Driver.
  * 
  * @return the Driver connected to the GUI
  */
 public Driver getDriver()
 {
   return this.driver;
 } // end getDriver method
 
 /**
  * Get the name.
  * 
  * @return the patient's name
  */
 public String getName()
 {
   return this.name;
 } // end getName method
 
 /**
  * Get the date.
  * 
  * @return the appointment date
  */
 public String getDate()
 {
   return this.date;
 } // end getDate method
 
 /**
  * Get the doctor.
  * 
  * @return the doctor's name
  */
 public String getDoctor()
 {
   return this.doctor;
 } // end getDoctor method
 
 /**
  * Get the attending nurse.
  * 
  * @return the nurse's name
  */
 public String getNurse()
 {
   return this.nurse;
 } // end getNurse method
 
 /**
  * Get the symptoms.
  * 
  * @return the symptoms
  */
 public String getSymptoms()
 {
   return this.symptoms;
 } // end getSymptoms method
 
 /**
  * Get the vitals.
  * 
  * @return the vitals
  */
 public String getVitals()
 {
   return this.vitals;
 } // end getVitals method
 
 /**
  * Get the diagnosis.
  * 
  * @return the diagnosis
  */
 public String getDiagnosis()
 {
   return this.diagnosis;
 } // end getDiagnosis method
 
 /**
  * Get the doctor's orders.
  * 
  * @return the doctor's orders
  */
 public String getDoctorsOrders()
 {
   return this.doctorsOrders;
 } // end getDoctorsOrders method

 /**
  * This private inner class implements ActionListener for btnEdit.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener1 implements ActionListener
 {
   /**
    * Field tr: the SysAdminPatientTR being used
    */
   private SysAdminPatientTR tr;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param tr the SysAdminPatientTR being used
    */
   private ButtonListener1(SysAdminPatientTR tr)
   {
     this.tr = tr;
     this.driver = tr.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     //call IOConverter to update TreatmentRecord
     this.tr.btnEdit.setText("Updated");
   } // end actionPerformed method
 } // end SysAdminPatientTR class
 
 /**
  * This private inner class implements ActionListener for btnBackToPatient.
  * 
  * @author Group 17
  * @version 1
  */
  private class ButtonListener2 implements ActionListener
 {
    /**
     * Field tr: the SysAdminPatientTR being used
     */
   private SysAdminPatientTR tr;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param tr the SysAdminPatientTR being used
    */
   private ButtonListener2(SysAdminPatientTR tr)
   {
     this.tr = tr;
     this.driver = tr.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new SysAdminPatientListTR(this.driver,this.tr.getName()));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener2 class
} // end SysAdminPatientTR class